Tables are the major new addition of HTML 3.0. They have been eagerly anticipated by many, not only for the desirable capability of organising tabular data such as statistics by row and column, but especially for the feature of laying out any elements of the HTML language. Probably the major single example of this, is forms layout. Until now, they were often laid out by preformatting, which although it ensures that grouped elements remain grouped (such as a text entry field and its label), presented text in typewriter font only.At the time of writing this, there was no official standard for HTML tables. They were part of the HTML 3.0 draft specification, which had lapsed. This work is currently being progressed as a number of smaller documents. The description given here is based on the currently available information from the draft specifications documents at W3C, with some influence from Microsoft's and Netscape's implementation. There are notable differences between the implementations; Microsoft's is closer to the W3C specification while Netscape's is more idiosyncratic. You are advised to check your tables in multiple browsers..
<Table border=2> <caption> Basic Table Structure </caption> <tr> <th> ... </th> <th> ... </th> ... </tr> <tr> <th> ... </th> <td> ... </td> ... </tr> ... </Table>
- Tables start with an optional caption followed by one or more rows. <tr> ... </tr>
- Each row is formed by one or more cells, which are differentiated into header <th> ... </th> and data cells <td> ... </td>
- Cells can be merged across rows and columns.
- The model provides limited support for control over appearance, for example horizontal and vertical alignment of cell contents, border styles and cell margins.
The TABLE attributes are all optional. By default, the table is rendered without a surrounding border. The table is generally sized automatically to fit the contents, but you can also set the table width using the WIDTH attribute. BORDER, CELLSPACING and CELLPADDING provide further control over the table's appearence. The ALIGN attribute can be used to position the table to the LEFT, CENTER or RIGHT. The CAPTION element is used for captions. These are rendered at the top or bottom of the table depending on the optional ALIGN attribute.
Each table row is contained in a TR element, although the end tag can always be omitted (in principle; some browsers don't handle this well).
Table cells are defined by TD elements for data and TH elements for headers. Like TR, these are containers and can be given without trailing end tags (in principle; some browsers don't handle this well). TH and TD support several attributes: ALIGN and VALIGN for aligning cell content, ROWSPAN and COLSPAN for cells which span more than one row or column. A cell can contain a wide variety of other block and text level elements including form fields and other tables.
Tables can contain a wide range of content, such as headers, lists, paragraphs, forms, figures, preformatted text and even nested tables.
An Example Table Tags Cell Tag Attributes
|
---|